const app = getApp()
const util = require("../../utils/util.js");
Page({
  data: {
    headpic:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fi1.sinaimg.cn%2FIT%2F2010%2F0419%2F201041993511.jpg&refer=http%3A%2F%2Fi1.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1619426450&t=1fbb311a8f2a66342db0ac42e77f33e8',
    currentTime: "",
    curdate:'',
    flag: "none"  
  },
  onLoad:function(){
    var that=this;
    wx.setNavigationBarTitle({ title: '首页' })

    setInterval(function () {
      const _currentTime = util.formatTime(new Date()).split(" ")[1];
      
      that.setData({
        currentTime: _currentTime,
      
        flag: "block"
      });
    }, 1000)

    var timestamp = Date.parse(new Date());
    var date = new Date(timestamp);
    //获取年份  
    var Y =date.getFullYear();
    //获取月份  
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
    //获取当日日期 
    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
    that.setData({
      curdate: Y+'-'+M+'-'+D,
    
 
    });
  },
  qiandao:function(){
      wx.navigateTo({
        url: '../main/qiandao/qiandao',
      })
  },
  onShow:function(){
    var that=this;
    var uid = wx.getStorageSync('uid');
    wx.request({
      url: app.globalData.baseUrl +'/user/getUserInfo', // 仅为示例，并非真实的接口地址
      // url: app.globalData.url.login,
      method: 'post',
      data: {

        id: uid
      },
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function (res) {
        console.log(res.data);
        if (res.data.code == 0) {
          if (res.data.data != null) {
          
                that.setData({

                  headpic: res.data.data.img, //请求结果数据

                })
           


          }
        }

      }
    })
  }



})